#-*- coding:utf-8 -*-
import os
import imp
import sys
import time
import json
import logging
import traceback
import urllib
import urllib2
import httplib
import gevent
import gevent.monkey
gevent.monkey.patch_all()
from gevent.queue import Queue

from common import core

reload(sys)
sys.setdefaultencoding('utf8')
FastpyAutoUpdate = True





class dbsample():
    def __init__(self):
        # init here
        self.mysqlPool = core.MysqlPool(pool_size=20,host='10.13.41.225',port=3306,user='artqiyi_100',passwd='artqiyi@123',db='test',charset='utf8')
        pass

    def test_mysql_pool(self, request, response_head):
	conn = self.mysqlPool.get()
        sql = "select * from play_url where uid = 52 and video_len > 0 order by id desc LIMIT 0,10"
        conn.execute(sql)
        rows = conn.fetchall()
        sql = "select count(*) as count from play_url where uid = 52 and video_len > 0"
        conn.execute(sql)
        rows2 = conn.fetchall()

        self.mysqlPool.put(conn)
        res = json.dumps(str(rows2), ensure_ascii=True).encode('utf-8')

        return res

